package com.cjj.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.cjj.common.convention.result.Result;
import com.cjj.common.convention.result.Results;
import com.cjj.dao.entity.TeacherInfo;
import com.cjj.dto.req.GetTeacherInfoListReqDTO;
import com.cjj.dto.req.ReviewTeacherInfoReqDTO;
import com.cjj.dto.req.TeacherInfoReqDTO;
import com.cjj.service.TeacherInfoService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/teacherInfo")
@RequiredArgsConstructor
public class TeacherInfoController {

    private final TeacherInfoService teacherInfoService;


    /**
     * 上传教师信息
     */
    @PostMapping("/upload")
    public Result<Void> uploadTeacherInfo(@RequestBody TeacherInfoReqDTO teacherInfoReqDTO) {
        teacherInfoService.uploadTeacherInfo(teacherInfoReqDTO);
        return Results.success();
    }

    /**
     * 分页查询所有不可用的教师信息
     * @param pageNum 页数
     * @param pageSize 页面大小
     * @return
     */
    @GetMapping("/getNotAvailable")
    public Result<IPage<TeacherInfo>> getPendingReviewOrders(
            @RequestParam(defaultValue = "1") Integer pageNum,
            @RequestParam(defaultValue = "10") Integer pageSize) {
        IPage<TeacherInfo> page = teacherInfoService.getNotAvailable(pageNum, pageSize);
        return Results.success(page);
    }


    /**
     * 多条件分页查询
     */
    @GetMapping("/list")
    public Result<IPage<TeacherInfo>> getTeacherInfoList(
            @RequestParam(defaultValue = "1") Integer pageNum,
            @RequestParam(defaultValue = "10") Integer pageSize,
            @RequestBody GetTeacherInfoListReqDTO GetTeacherInfoListReqDTO){

        IPage<TeacherInfo> page = teacherInfoService.getTeacherInfoList(pageNum, pageSize,GetTeacherInfoListReqDTO);
        return Results.success(page);
    }

    /**
     * 批量审核教师信息
     */
    @PutMapping("/reviewTeacherInfo")
    public Result<Void> reviewTeacherInfo(@RequestBody ReviewTeacherInfoReqDTO reviewTeacherInfoReqDTO){
        teacherInfoService.reviewTeacherInfo(reviewTeacherInfoReqDTO);
        return Results.success();
    }
}
